<?php if (!defined('BASEPATH'))exit('No direct script access allowed');

class Task extends MY_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('task_model');
        $this->load->model('subtasks_model');
        $this->assign("action", "task");
    }

    //首页
    function index()
    {
        $cat = $_REQUEST['cat'];
        //广告轮标图
        $banner_list = $this->db->query("select banner_img,banner_link,title from tan_banner where type = 8 and status = 1 order by sort desc limit 3")->result_array();
        $this->assign("banner_list", $banner_list);
        if ($cat){
            $this->display('task/catindex.html');
        }else{
            $this->display('task/index.html');
        }

    }


    //详情页
    function detail($task_id)
    {
        $tid = decrypt_wenda_id($task_id);
        $task = $this->task_model->task_detail($tid);

        if (!$task) {
            $this->assign("error", "您查找的任务不存在");
            $this->display('deleted/index.html');
            exit;
        }
        //判断是否是发布方自己的任务，

        $web_config = $this->task_model->website_config();
        $is_login = empty($this->user_id) ? 0 : 1;
        $task['surplus'] = $task['sub_num'] - $task['snum'];
        if($task['cate_id'] == 4){
            $temp_where = array('tid'=>$tid,'is_end !='=>1);
            //如果这个任务被领过，就不能再被领取
            $sql = "select * from tan_subtasks where tid=$tid and is_end!=1";
            $subtask_list = $this->db->query($sql)->row_array();
            $is_zero = empty($subtask_list)?0:1;
        }elseif($task['cate_id'] == 3){
            $investment_money = $this->task_model->subtask_invest_money_count($task['tid']);
            $is_zero = $task['investment_money_amount'] <= $investment_money?1:0;//1表示已经领取完
        }else{
            $is_zero = $task['sub_num'] <= $task['snum']?1:0;//1表示已经领取完
        }
        $is_end = $task['is_end'];
        $left_time = -1;
        $dead_time = (int)$web_config['task_fail_period'];
        if ($is_login) {
            $is_my_task = $this->task_model->task_is_my($tid, $this->user_id);
            $my_subtask = $this->subtasks_model->my_subtask($tid, $this->user_id);
            if ($is_my_task) {
                $status = 1;//发布方的任务，显示编辑
            } elseif ($is_end) {
                $status = 2;
            } elseif (!$my_subtask && $is_zero) {
                //没有申请过任务并且任务已经领完，显示已领完
                $status = 3;
            } elseif (!$my_subtask && !$is_zero) {
                //没有申请过任务并且任务数还够，显示立即申请
                $status = 4;
            } elseif ($my_subtask && $my_subtask['is_post'] == 0) {
                //未提交认证显示提交认证,需要提供一个left_time,
                $time_dif = time() - $my_subtask['add_time'];
                $left_time = ($dead_time * 3600 - $time_dif) < 0 ? 0 : $dead_time * 3600 - $time_dif;
                $status = 5;
                
                if($task['cate_id'] == 4){
                    $status = 7;
                }
            } elseif ($my_subtask && $my_subtask['is_post'] == 1 && $my_subtask['status'] == 0) {
                //已提交认证 子任务没有被审核，显示修改认证和查看
                $status = 6;
            } elseif ($my_subtask && $my_subtask['is_post'] == 1 && $my_subtask['status'] == 1) {
                //已提交认证 子任务没有被审核，只显示查看
                $status = 7;
            } elseif ($my_subtask['status'] == 2) {
                //申诉中显示查看
                $status = 8;
            } else {
                $status = -1;
            }
        } else {
            if ($is_end) {
                $status = 2;
            } elseif ($is_zero) {
                //没有申请过任务并且任务已经领完，显示已领完
                $status = 3;
            } else {
                $status = 4;
            }
        }
//        $is_update = 0;
//        if($task['is_post']==1 && $task['status']!=1 && $task['is_end']==0){
//            $is_update = 1;
//        }
        if ($task['task_tag']) {
            $task['task_tags'] = explode(',', $task['task_tag']);
        }
        $task['logo'] = $task['logo'] ? $task['logo'] : "/static/default/img/nopic.png";
        $task['commission'] = 1.0 * $task['commission'] / 10000;//重新换算成人民币
        /* lht 2018/5/18 14:53 佣金区间 */
        $task['min_commission'] = round(1.0 * $task['commission_per'] * $task['min_investment_money']/100) ;
        $task['max_commission'] = round(1.0 * $task['commission_per'] * $task['max_investment_money']/100) ;

        $task['profit_amount'] = $task['commission'] + $task['expected_money'] + $task['bonus'];//预期总收益
        $task['img_list'] = $task['img_list'] ? explode(',', $task['img_list']) : array();
        $task['validate'] = $task['validate'] ? explode(',', $task['validate']) : array();
        $recommend_where = "t.is_delete=0 and t.status=1 and t.cate_id=" . $task['cate_id'] . " and t.tid<>" . $task['tid'];
        $recommend_list = $this->task_model->task_list($recommend_where, 1, 4);
        foreach ($recommend_list as $reitem => $reval) {
            $recommend_list[$reitem]['link'] = "/task/" . encrypt_wenda_id($reval['tid']) . ".html";
            $recommend_list[$reitem]['surplus'] = $reval['sub_num'] - $reval['snum'];
            $recommend_list[$reitem]['logo'] = $reval['logo'] ? $reval['logo'] : "/static/default/img/nopic.png";
            $recommend_list[$reitem]['commission'] = 1.0 * $reval['commission'] / 10000;
            $recommend_list[$reitem]['surplus'] = $reval['sub_num'] - $reval['snum'];
            $recommend_list[$reitem]['overplus'] = ($recommend_list[$reitem]['surplus'] / $reval['sub_num']) * 100;
            $recommend_list[$reitem]['profit_amount'] = $recommend_list[$reitem]['commission'] + $reval['expected_money'] + $reval['bonus'];
            if ($reval['task_tag']) {
                $task_tag = explode(',', $reval['task_tag']);
                foreach ($task_tag as $tag_key => $tag_val) {
                    $recommend_list[$reitem]['tag_span'] .= '<span class="label">' . $tag_val . '</span>';
                }
            }
        }

        $task['_invite'] = empty($task['invite_code']) ? 0 : 1;
        $task['tid'] = $task_id;//虚的tid
        //剩余可领取的额度
        $task['min_over'] = $task['min_investment_money'];
        $investment_money = $this->task_model->subtask_invest_money_count($tid);
        $task['max_over']= $task['investment_money_amount']-$investment_money;
        $task['can_recive_money'] = $task['max_over'] > $task['max_investment_money']? $task['max_investment_money']:$task['max_over'] ;
        $this->assign('dead_time',$dead_time);
        $this->assign('left_time', $left_time);
        $this->assign('status', $status);
        $this->assign('task', $task);
        $this->assign('recommend_list', $recommend_list);
        $this->display('task/detail.html');
    }

    //任务列表
    function task_list()
    {
        $search_list = $this->task_model->search_list();
        //var_dump($search_list);exit();
        $cate_id = $_POST['cate_id'];
        $investment_day = $_POST['investment_day'];
        $investment_money = $_POST['investment_money'];
        $task_tag = $_POST['task_tag'];
        $pageIndex = isset($_POST['pageIndex']) ? trim($_POST['pageIndex']) : 0;
        $where = " t.is_delete=0 and t.status=1 and t.cate_id!=4";
        //任务类型
        if ($cate_id > 0) {
            $where .= " and t.cate_id={$cate_id}";
        }
        //$overplus $surplus $profit_amount
        //投资天数
        if ($investment_day > 0) {
            $min = $search_list['investment_day']['data'][$investment_day]['min'];
            $max = isset($search_list['investment_day']['data'][$investment_day]['max']) ? $search_list['investment_day']['data'][$investment_day]['max'] : -1;
            if ($max < 0) {
                $where .= " and t.investment_day>{$min}";
            } else {
                $where .= " and t.investment_day>{$min} and t.investment_day<={$max}";
            }
        }

        //投资金额
        if ($investment_money > 0) {
            $min = $search_list['investment_money']['data'][$investment_money]['min'];
            $max = isset($search_list['investment_money']['data'][$investment_money]['max']) ? $search_list['investment_money']['data'][$investment_money]['max'] : -1;
            if ($max < 0) {
                $where .= " and t.investment_money>{$min}";
            } else {
                $where .= " and t.investment_money>{$min} and t.investment_money<={$max}";
            }
        }
        //标签
        if ($task_tag > 0) {
            $tag_name = $search_list['task_tag']['data'][$task_tag]['word'];
            $where .= " and t.task_tag like '%{$tag_name}%' ";
        }

        $records_per_page = 12;
        $totalCount = $this->task_model->task_count($where);
        $list = $this->task_model->task_list($where, $pageIndex + 1, $records_per_page);
        foreach ($list as $key => $val) {
            $temp_tid = encrypt_wenda_id($val['tid']);
            $surplus = $val['sub_num'] - $val['snum'];
            $overplus = ($surplus / $val['sub_num']) * 100;
            $list[$key]['logo'] = $val['logo'] ? $val['logo'] : "/static/weixin/img/nopic.png";
            $link = "/task/{$temp_tid}.html";
            $list[$key]['commission'] = 1.0 * $val['commission'] / 10000;
            $can_recieve = 1;//默认可以领取
            if ($val['task_tag']) {
                $task_tags = explode(',', $val['task_tag']);
                $tag_span = "";
                foreach ($task_tags as $tag_key=>$tag){
                    $tag_span .= "<span>".$tag."</span>";
                }
                $list[$key]['tag_span'] = $tag_span;
            }
            if ($val['cate_id'] == 1) {
                $profit_amount = $list[$key]['commission'] + $val['expected_money'] + $val['bonus'];
                if($surplus <=0){
                    $can_revieve = 0;
                }
            } else if ($val['cate_id'] == 3) {

                $investment_money = $this->task_model->subtask_invest_money_count($val['tid']);
                $list[$key]['surplus_money'] = $val['investment_money_amount']-$investment_money;
                if($val['investment_money_amount'] - $investment_money <= 0){
                    $can_recieve = 0;
                }
                $profit_amount = round($list[$key]['commission_per']*$list[$key]['max_investment_money']/100);
            } elseif($val['cate_id'] == 4){
                $sql = "select * from tan_subtasks where tid={$val['tid']} and is_end!=1";
                $subtask_list = $this->db->query($sql)->row_array();
                $can_revieve = empty($subtask_list)?1:0;
            }else {
                if($surplus <=0){
                    $can_recieve = 0;
                }
                $profit_amount = 0;
            }
            $list[$key]['profit_amount'] = $profit_amount;
            $list[$key]['overplus'] = $overplus;
            $list[$key]['link'] = $link;
            $list[$key]['surplus'] = $surplus;
            $list[$key]['tid'] = $temp_tid;
            $list[$key]['can_recieve'] = $can_recieve;;
        }
        $result = array(
            "reqStatus" => true,
            "data" => array(
                "totalCount" => $totalCount ? $totalCount : 0,
                "pageIndex" => $pageIndex,
                "list" => $list
            )
        );
        echo json_encode($result, JSON_HEX_TAG);
        die;
    }

    //搜索条件列表
    function search_list()
    {
        $search_list = $this->task_model->search_list();

        $res = array(
            'code' => 1,
            'data' => $search_list,
        );

        echo json_encode($res, JSON_HEX_TAG);exit();
    }

    //申请（领取）任务
    function ajax_apply()
    {
        if (!$this->user_id){
            $url = site_url("account/login")."?redirectUrl=" . $_SERVER['HTTP_REFERER'];
            $result = array(
                "reqStatus" => true,
                'msg' => '请先登录',
                'link' => $url,
            );
            echo json_encode($result, JSON_HEX_TAG);
            die;
        }
        $apply_investment_money = $_REQUEST['investment_money'];
        //1.自己的任务不能领取
        $tid = decrypt_wenda_id($_POST['tid']);//真实id
        $invite_code = empty($_POST['invite_code']) ? "" : $_POST['invite_code'];
        $uid = $this->user_id;
        $link = "/task/{$_POST['tid']}.html";
        $task = $this->task_model->task_detail($tid);
        if($task['is_pause']==1){
            $result = array(
                "reqStatus" => true,
                'msg'=>'此任务已暂停领取',
                'link'=>$link,
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }
        if ($this->task_model->task_is_my($tid, $uid)) {
            $result = array(
                "reqStatus" => true,
                'msg' => '此任务为您发布的任务',
                'link' => $link,
            );
        } else {
            if (!$this->subtasks_model->my_subtask($tid, $uid)) {
                //判断任务是否需要邀请码
                if (!empty($task['invite_code']) && empty($invite_code)) {
                    $result = array(
                        "reqStatus" => true,
                        'msg' => '此任务领取需要邀请码',
                        'link' => $link,
                    );
                    echo json_encode($result, JSON_HEX_TAG);
                    die;
                }
                if (!empty($task['invite_code']) && $task['invite_code'] != $invite_code) {
                    $result = array(
                        "reqStatus" => true,
                        'msg' => '邀请码错误',
                        'link' => $link,
                    );
                    echo json_encode($result, JSON_HEX_TAG);
                    die;
                }

                if ($task['cate_id'] == 3) {
                    $investment_money = $this->task_model->subtask_invest_money_count($tid);
                    $surplus_money = $task['investment_money_amount'] - $investment_money;
                    $insert_arr = array(
                        'uid' => $uid,
                        'tid' => $tid,
                        'task_sn' => 'S' . date('YmdHis') . rand(1000, 9999),
                        'add_time' => time(),
                        'investment_money'=>$apply_investment_money
                    );
                    $task = $this->task_model->task_detail($tid);
                    $msg = "领取成功";
                    if ($surplus_money<=0) {
                        $result = array(
                            "reqStatus" => true,
                            'msg' => "任务已领完",
                            'link' => $link,
                        );
                        echo json_encode($result,JSON_HEX_TAG);die;
                    }elseif($apply_investment_money>$surplus_money){
                        $result = array(
                            "reqStatus" => true,
                            'msg' => "超过可领取限制",
                            'link' => $link,
                        );
                        echo json_encode($result,JSON_HEX_TAG);die;
                    }

                    if($apply_investment_money<$task['min_investment_money'] || $apply_investment_money>$task['max_investment_money']){
                        $result = array(
                            "reqStatus" => true,
                            'msg' => "领取金额错误",
                            'link' => $link,
                        );
                        echo json_encode($result,JSON_HEX_TAG);die;
                    }
                    $this->subtasks_model->add_task($insert_arr);
                    $sid = $this->db->insert_id();
                    $result = array(
                        "reqStatus" => true,
                        'msg' => $msg,
                        'link' => $link,
                    );
                    //添加Log
                    $log_content = $this->task_model->log_content();
                    $log_arr = array(
                        'type_id' => $sid,
                        'uid' => $uid['user_id'],
                        'type' => 2,
                        'content' => $log_content['add_subtasks'],
                        'add_time' => time(),
                    );
                    $this->task_model->add_subtasks_log($log_arr);

                } else {
                    $num = $this->subtasks_model->count_subtask($tid);
                    if ($num < $task['sub_num']) {
                        $insert_arr = array(
                            'uid' => $uid,
                            'tid' => $tid,
                            'task_sn' => 'S' . date('YmdHis') . rand(1000, 9999),
                            'add_time' => time(),
                        );
                        $task = $this->task_model->task_detail($tid);
                        $msg = "领取成功";
                        if ($task['snum'] >= $task['sub_num']) {
                            $msg = '任务已领完';
                        }
                        if($task['cate_id'] == 4){
                            $insert_arr['qualification'] = 0;
                        }
                        $this->subtasks_model->add_task($insert_arr);
                        $sid = $this->db->insert_id();
                        $result = array(
                            "reqStatus" => true,
                            'msg' => $msg,
                            'link' => $link,
                        );
                        //添加Log
                        $log_content = $this->task_model->log_content();
                        $log_arr = array(
                            'type_id' => $sid,
                            'uid' => $uid,
                            'type' => 2,
                            'content' => $log_content['add_subtasks'],
                            'add_time' => time(),
                        );
                        $this->task_model->add_subtasks_log($log_arr);
                    } else {
                        $result = array(
                            "reqStatus" => true,
                            'msg' => "任务已被领完",
                            'link' => $link
                        );
                    }
                }




            } else {
                $result = array(
                    "reqStatus" => true,
                    'msg' => '已有申请',
                    'link' => $link,
                );
            }
        }
        //2.不能重复领取

        //判断这个人这个任务是不是有正在进行中的，有就什么都不干，直接跳到详情页


        echo json_encode($result, JSON_HEX_TAG);
        die;
    }
    function ajax_cancel_apply(){
        //is_end=2 status=4

        $tid = decrypt_wenda_id($_POST['tid']);//真实id
        $uid = $this->user_id;
        //没登录返回没有登录的信息
        if (!$this->user_id){
            $url = site_url("account/login")."?redirectUrl=" . $_SERVER['HTTP_REFERER'];
            $result = array(
                "reqStatus" => true,
                'msg' => '请先登录',
                'link' => $url,
            );
            echo json_encode($result, JSON_HEX_TAG);
            die;
        }
        //
        $update_data = array(
            'is_end'=>2,
            'status'=>4
        );
        $where = array('tid'=>$tid,'uid'=>$uid);
        if($this->subtasks_model->update_subtask($update_data,$where)) {
            //判断任务是否需要邀请码
            $result = array(
                "reqStatus" => true,
                'msg' => '申请成功',
            );
            echo json_encode($result, JSON_HEX_TAG);
            die;
        }else{
            $result = array(
                "reqStatus" => true,
                'msg' => '申失败',
            );
            echo json_encode($result, JSON_HEX_TAG);
            die;
        }

    }
    //提交验证信息的页面
    function info(){
        // 这个任务 提交的验证条件
        $this->is_login();
        $type = $_GET['type'];
        $title="提交验证";
        if ($type==2){
            $title="修改验证";
        }
        $real_tid = decrypt_wenda_id($_GET['tid']); ;
        $task = $this->task_model->task_detail($real_tid);
        $uid = $this->user_id;

        //获取subtask的validate，
        $sql = "select * from tan_subtasks where uid={$uid} and tid={$real_tid} and is_end=0";
        $subtask_info = $this->db->query($sql)->row_array();
        if(empty($subtask_info)){
            $url = site_url("task").$this->get_next_request_url();
            header("Location:".$url);
            exit;
        }
        $sub_validate = unserialize($subtask_info['validate']);

        $res = array(
            'validate'=>$task['validate']?(strpos($task['validate'],',') ? explode(',',$task['validate']) : array($task['validate'])) : array(),
            'img_list'=>$task['img_list']?(strpos($task['img_list'],',') ? explode(',',$task['img_list']) : array($task['img_list'])) : array(),
            'tid'=>$_GET['tid'],
        );
        $this->assign('title',$title);
        $this->assign('validate',$sub_validate);
        $this->assign('task',$res);
        $this->display('task/info.html');
//        $res = array(
//            'validate'=>$task['validate']?(strpos($task['validate'],',') ? explode(',',$task['validate']) : array($task['validate'])) : array(),
//            'img_list'=>$task['img_list']?(strpos($task['img_list'],',') ? explode(',',$task['img_list']) : array($task['validate'])) : array(),
//            'tid'=>$task['tid'],
//        );
//
//        echo json_encode($res, JSON_HEX_TAG);
//        exit;
    }

    //提交验证信息
    function submit_validate(){
        if(!$this->user_id){
            $url = site_url("account/login").$this->get_next_request_url();
            $result = array(
                "reqStatus" => false,
                "data" => array(),
                "msg"=>'请先登录',
                "link"=>$url,
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }
        $validate = array();
        if(isset($_POST['name'])){
            $validate['name'] = $_POST['name'];
        }

        if(isset($_POST['phone'])){
            $validate['phone'] = $_POST['phone'];
        }

        if(isset($_POST['identity'])){
            $validate['identity'] = $_POST['identity'];
        }

        if(isset($_POST['img_list'])){
            $validate['img_list'] = $_POST['img_list'];
        }
        $tid = decrypt_wenda_id($_POST['tid']);
        $uid = $this->user_id;
        //找子任务信息
        $sql = "select * from tan_subtasks where uid={$uid} and tid={$tid} and is_end=0";

        $subtask_info = $this->db->query($sql)->row_array();
        if(empty($subtask_info)){
            $result = array(
                "reqStatus" => false,
                "data" => array(),
                "msg"=>'数据异常，请稍候重试',
                "link"=>'/task/'.$_POST['tid'].'.html',
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }
        $sid = $subtask_info['sid'];
        $where = array('sid'=>$sid);
        $update_arr = array(
            'validate'=>serialize($validate),
            'is_post'=>1,
            'receive_time'=>time(),
        );
        $this->subtasks_model->update_subtask($update_arr,$where);
        $result = array(
            "reqStatus" => true,
            "data" => array(),
            "msg"=>'提交成功',
            "link"=>'/task/'.$_POST['tid'].'.html',
        );

        //添加Log
        $log_content =  $this->task_model->log_content();
        $log_arr = array(
            'type_id'=>$sid,
            'uid'=>$this->user_id,
            'type' => 2,
            'content'=>$log_content['validate'],
            'add_time'=>time(),
        );
        $this->task_model->add_subtasks_log($log_arr);
        echo json_encode($result,JSON_HEX_TAG);die;

    }

    //任务跳转到外部链接
    function task_redirect(){
        $tid = $_GET['tid']?decrypt_wenda_id($_GET['tid']):0;

        $task = $this->task_model->task_detail($tid);
        $tid =1;
        $data['type'] = 2;
        $data['type_val'] = $tid;//任务id
        $data['jump_url'] = $task['redirect_url'];
        $data['request_ip'] = $this->input->ip_address();
        $data['request_from'] = $_SERVER['HTTP_REFERER'];
        $data['request_time'] = time();
        $this->task_model->add_reload_log($data);
        redirect($task['redirect_url']);
    }


    private function is_login(){
        if(!$this->user_id){
            $url = site_url("account/login").$this->get_next_request_url();
            header("Location:".$url);
            exit;
        }
    }
    
    public function task_bb_list(){
        $pageIndex = isset($_REQUEST['pageIndex']) ? trim($_REQUEST['pageIndex']) : 0;
        $where = " t.cate_id=4 ";
        $records_per_page = 12;
        $totalCount = $this->task_model->task_count($where);
        $list= $this->task_model->task_list($where,$pageIndex+1,$records_per_page);
        foreach ($list as $key=>$val){
            $sql = "select * from tan_subtasks where tid={$val['tid']} and is_end!=1";
            $subtask_list = $this->db->query($sql)->row_array();
            $can_recieve = empty($subtask_list)?1:0;
            if ($val['task_tag']) {
                $task_tags = explode(',', $val['task_tag']);
                $tag_span = "";
                foreach ($task_tags as $tag_key=>$tag){
                    $tag_span .= "<span>".$tag."</span>";
                }
                $list[$key]['tag_span'] = $tag_span;
            }
            $temp_tid = encrypt_wenda_id($val['tid']);
            $list[$key]['logo'] = $val['logo'] ? $val['logo'] : "/static/weixin/img/nopic.png";
            $list[$key]['can_recieve'] = $can_recieve;
            $link = "/task/{$temp_tid}.html";
            $list[$key]['commission'] = 1.0 * $val['commission'] / 10000;
            $list[$key]['link'] = $link;
        }
        $result = array(
            "reqStatus" => true,
            "data" => array(
                "totalCount" => $totalCount ? $totalCount : 0,
                "pageIndex" => $pageIndex,
                "list" => $list
            )
        );
        echo json_encode($result,JSON_HEX_TAG);die;
    }

    public function end_subtask(){
        //tid uid sid 去检查
        if(!$this->user_id){
            $url = site_url("account/login").$this->get_next_request_url();
            $result = array(
                "reqStatus" => false,
                "data" => array(),
                "msg"=>'请先登录',
                "link"=>$url,
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }
        $tid = decrypt_wenda_id($_REQUEST['tid']);
        $sid = decrypt_wenda_id($_REQUEST['sid']);
        $user_info = $this->bbs_userinfo;
        $uid = $this->user_id;
        //检查是否是uid发布的任务还是自己的任务
        $sql = "select s.uid suid,t.uid tuid from tan_subtasks s left join tan_task t on s.tid = t.tid where s.sid={$sid}";
        $subtask_info = $this->db->query($sql)->row_array();
        if($subtask_info['tuid'] == $uid || $subtask_info['suid'] == $uid){
            $update_sql = "update tan_subtasks set apply_end=1 where sid={$sid}";
            $this->db->query($update_sql);
            $result = array(
                "reqStatus" => true,
                'msg'=>'更新成功',
                'code'=>0,
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }else{
            $result = array(
                "reqStatus" => true,
                'msg'=>'非发布方或者领取方操作',
                'code'=>0,
            );
            echo json_encode($result,JSON_HEX_TAG);die;
        }
    }
}
